/*
 * Copyright (c) 2018. 玺得（深圳）科技有限公司.保留所有权利. http://www.pi-top.com/ 玺得（深圳）科技有限公司保留所有代码著作权.如有任何疑问请访问官方网站与我们联系. 代码只针对特定需求定制编码，不得在未经允许或授权的情况下对外传播扩散.恶意传播者，法律后果自行承担. 本代码仅用于pps-cloud系统.
 */
package com.pitop.further.ctrl;

import com.pitop.core.tools.redis.RedisUtils;
import com.pitop.serial.entity.SerialNumber;
import com.pitop.serial.service.SerialNumberSV;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 工厂管理 控制器
 *
 * @author pi-top
 */
@RestController
@RequestMapping("/further")
@Slf4j
@Api(value = "further管理控制器", description = "further管理控制器")
public class FurtherCtrl {

    @Resource
    private SerialNumberSV serialNumberSV;

    @Resource
    protected RedisUtils redisUtils;

    /**
     * 根据barcode查询serial number
     *
     * @param barcode 序列号
     * @return BeanRet
     */
    @ApiOperation(value = "根据barcode查询serial number息", notes = "根据barcode查询serial number")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "barcode", value = "sn", dataType = "java.lang.String", paramType = "query")
    })
    @GetMapping(value = "/load/barCode/{barCode}")
    @ResponseBody
    public SerialNumber loadBarCode(String barcode) {
        if (barcode == null) {
            return null;
        }
        return serialNumberSV.loadBySnCode(barcode);
    }


    /**
     * 根据serial number查询barcode
     *
     * @param serialNumber
     * @return BeanRet
     */
    @ApiOperation(value = "根据serial number查询barcode", notes = "根据serial number查询barcode")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "serial", value = "序列号", dataType = "java.lang.String", paramType = "query")
    })
    @GetMapping(value = "/load/serial/{serial}")
    @ResponseBody
    public SerialNumber loadSerial( String serial) {
        if (serial == null) {
            return null;
        }
        return serialNumberSV.loadBySn(serial);
    }


}
